﻿using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using UserManager.Models;
using UserManager.ViewModel;

namespace UserManager;

/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
        
        MainViewModel vm = new();
        DataContext = vm;
    }

    private void FilterTextBox_OnTextChanged(object sender, TextChangedEventArgs e)
    {
        UserList.Items.Filter = FilterMethod;
    }

    private bool FilterMethod(object obj)
    {
        var user = obj as User;
        return user.Name.Contains(FilterTextBox.Text, StringComparison.OrdinalIgnoreCase);
    }
}